<?php

class User_model extends CI_Model 
{
    function __construct()
    {
        parent::__construct();
    }

    function authenticate($username, $password)
    {
    	$this->db->select('*');
		$this->db->from('Utenti');
		$this->db->where('username',$username);
		$this->db->where('password',do_hash($password));
		$this->db->where('role','admin');

		$query = $this->db->get();

		if ($query->num_rows() > 0)
		{
			return $query->row();
		}
		else
		{
			return null;
		}
    }
}

?>